<!-- 擒龙形态 -->
<template>
  <div class="wrap" id="app">
    <div class="tag flex">
      <span
        class="item"
        v-for="(item, index) in columns"
        :key="item.cId"
        :class="{ cur: cId == item.cId }"
        @click="tag(index)"
        >{{ item.categoryName }}</span
      >
    </div>
    <div class="box flex">
      <div
        class="content flex"
        :style="{ background: 'url(' + imgSrc + ') no-repeat center' }"
      >
        <div class="txt">
          {{ categoryProfile }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getColumn, getStrategyStockPoolList } from "../api/api";
import dayjs from "dayjs";
export default {
  data() {
    return {
      columns: [],
      cId: "",
      productColumnId: location.href.indexOf("test") > -1 ? 78 : 53,
      imgSrc: "",
      categoryProfile: "",
    };
  },
  mounted() {
    document.title = "擒龙形态1";
    this.getColumn();
  },
  methods: {
    async getColumn() {
      await getColumn({
        productColumnId: this.productColumnId,
      }).then((back) => {
        if (back.status == 1) {
          let data = back.data;
          this.columns = data.filter(
            (item) =>
              item.categoryName == "主力狙击" ||
              item.categoryName == "短线跟庄" ||
              item.categoryName == "强势挖掘"
          );
          this.tag(0);
        }
      });
    },
    blockStock(data) {
      const { stock, cId, productId, productColumnId } = data;
      window.prompt(
        "",
        `up://["user.info",${Date.now()},{"type":"擒龙形态","params":{"cId": ${cId},"productId":${productId},"productColumnId": ${productColumnId}},"data":{"stock":${stock}}}]`
      );
    },
    async tag(type = 0) {
      const column = [
        `${this.PIC_URL}/tlbypcWeb/tagColumn/zhulijuji_bg.png`,
        `${this.PIC_URL}/tlbypcWeb/tagColumn/dxgz_bg.png`,
        `${this.PIC_URL}/tlbypcWeb/tagColumn/qxwj_bg.png`,
      ][type];
      this.cId = this.columns[type].cId;
      this.imgSrc = column;
      this.categoryProfile = this.columns[type].categoryProfile;
      this.getStockList();
    },
    async getStockList() {
      const { productId, token } = this.$route.params;
      const params = {
        cId: this.cId,
        productId,
        productColumnId: this.productColumnId,
        clientCentralToken: token,
      };
      await getStrategyStockPoolList(params).then((back) => {
        if (back.status == 1) {
          let data = back.data;
          const stock = data.map((item) => ({
            id: item.id,
            stockCode: item.stockCode,
            blockName: item.themeName,
            subjectNature: item.themeType,
            date: dayjs(item.createTime).format("YYYY-MM-DD"),
            publishTime: dayjs(item.publishTime || Date.now()).format(
              "YYYY-MM-DD"
            ),
            teachingSeries: item.teachingSeries,
          }));
          this.blockStock({
            cId: this.cId,
            productId,
            productColumnId: this.productColumnId,
            stock: JSON.stringify(stock),
          });
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.wrap {
  width: 539px;
  border: 1px solid #313337;
  box-sizing: border-box;
  height: 100%;
  .tag {
    border-bottom: 1px solid #313337;
    height: 62px;
    align-items: center;
    justify-content: center;
    .item {
      font-size: 24px;
      color: #e5e5e5;
      width: 137px;
      height: 40px;
      line-height: 40px;
      text-align: center;
      margin: 0 27px;
      cursor: pointer;
      font-weight: bold;
      &.cur {
        color: #09090f;
        background: radial-gradient(
          circle,
          rgba(250, 198, 142, 1),
          rgba(197, 152, 96, 1)
        );
        border-radius: 4px;
        position: relative;
        &::after {
          content: "";
          display: block;
          position: absolute;
          width: 100%;
          height: 3px;
          background: #f5bb85;
          bottom: -10px;
          border-radius: 1px;
          right: 0;
        }
      }
    }
  }
  .box {
    justify-content: center;
    padding: 50px 0 0;
    .content {
      width: 446px;
      height: 626px;
      align-items: center;
      position: relative;
      justify-content: center;
      .txt {
        font-size: 22px;
        color: #ffffff;
        line-height: 35px;
        width: 242px;
        max-height: 319px;
        // position: absolute;
      }
    }
  }
}
</style>
